home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / GRAPTIES / SD204.LZH / LOADFILE.PAS < prev    next >
Pascal/Delphi Source File  |  1980-01-01  |  4KB  |  133 lines

  1. {======================================================================}
  2. UNIT LOADFILE;
  3.  
  4. INTERFACE
  5. USES IOSTUFF,CRT;
  6. PROCEDURE Load_ASCII(AFile : AnyStr);
  7. PROCEDURE Load_MEM(MFile : AnyStr);
  8. PROCEDURE Load_PAK(PFile:AnyStr);
  9.  
  10. IMPLEMENTATION
  11. VAR
  12.    TempStr : AnyStr;
  13.  
  14. {======================================================================}
  15. PROCEDURE Load_ASCII(AFile : AnyStr);
  16. {                                                     }
  17. { This routine loads an ASCII format file as created  }
  18. { by BOX onto the screen.                             }
  19. {                                                     }
  20.  
  21. VAR
  22.     FilevarA   : Text;
  23.     II         : Integer;
  24.  
  25. BEGIN
  26.       Assign(FilevarA,AFile);
  27.       {$I-} Reset(FilevarA); {$I+}
  28.       If IOresult = 0 then                        {found good file name}
  29.        Begin
  30.         ClrScr;
  31.         For II := 1 to 25 do
  32.         Begin
  33.          Readln(FilevarA,TempStr);
  34.          GoToXY(1,II);
  35.          Write(TempStr);
  36.         End;
  37.         Close(FilevarA);
  38.        End
  39.  
  40.       Else                                        {couldn't find file  }
  41.         Begin
  42.           GoToXY(1,24);
  43.           Write('ERROR - Could not find file');
  44.         End;
  45.  
  46. END; {Load_ASCII}
  47.  
  48. {======================================================================}
  49. PROCEDURE Load_MEM(MFile : AnyStr);
  50. {                                                     }
  51. { This routine loads a memory format file as created  }
  52. { by BOX directly into the video buffer.  Since a     }
  53. { memory format file is the same shape as the video   }
  54. { buffer, all that needs to be done is to move the    }
  55. { screen into the buffer with MoveToScreen in IOSTUFF.}
  56. {                                                     }
  57.  
  58. VAR
  59.     FilevarM   : File;
  60.     LoadScr    : Screen;
  61.  
  62. BEGIN
  63.       Assign(FilevarM,MFile);
  64.       {$I-} Reset(FilevarM,4000); {$I+}
  65.       If IOresult = 0 then                        {found good file name}
  66.         Begin
  67.           BlockRead(FilevarM,LoadScr,1);
  68.           MoveToScreen(LoadScr,Video^,4000);
  69.           Close(FilevarM);
  70.         End
  71.       Else                                        {couldn't find file  }
  72.         Begin
  73.           GoToXY(1,24);
  74.           Write('ERROR - Could not find file ',MFile);
  75.         End;
  76. END; {Load_MEM}
  77.  
  78. {======================================================================}
  79. PROCEDURE Load_PAK(PFile:AnyStr);
  80. {                                                     }
  81. { This procedure loads a Packed Format screen created }
  82. { by BOX.  The Packed format utilizes a run-length    }
  83. { encoding scheme that must be unpacked.  Each record }
  84. { in a Packed Format file is three bytes long. Byte 1 }
  85. { is the run length, i.e. the number of characters to }
  86. { repeat.  Byte 2 is the character to repeat and      }
  87. { byte 3 is the attribute of the character.           }
  88. {                                                     }
  89. TYPE
  90.    Pack        = Record
  91.                   PackNm : Byte;  {run length}
  92.                   PackCh : Char;  {repeated character}
  93.                   PackAt : Byte;  {repeated attribute}
  94.                  End;
  95.  
  96. VAR
  97.     FilevarM   : File;
  98.     LoadScr    : Screen;
  99.     Packbuf    : Array[1..2000] of Pack;
  100.     II,JJ,Sloc,SX,SY,NumRec  : Integer;
  101.  
  102. BEGIN
  103.    Sloc := 1;              {SLoc is location on screen}
  104.    Assign(FilevarM,PFile);
  105.    {$I-} Reset(FilevarM); {$I+}
  106.    If IOresult = 0 then          {found good file name}
  107.      Begin
  108.         BlockRead(FilevarM,PackBuf,48,NumRec);  
  109.         JJ := 0;
  110.         While Sloc < 2001 do 
  111.         Begin
  112.           JJ := JJ + 1;
  113.           For II := 1 to Packbuf[JJ].PackNm do  
  114.            Begin
  115.             SY := (SLoc-1) div 80 + 1;       {row}
  116.             SX := (SLoc-1) mod 80 + 1;       {column}
  117.             LoadScr[SY,SX].ScrCh := Packbuf[JJ].PackCh; 
  118.             LoadScr[SY,SX].ScrAt := Packbuf[JJ].PackAt;
  119.             SLoc := SLoc + 1;   
  120.            End;
  121.         End;
  122.         MoveToScreen(LoadScr,Video^,4000);
  123.         Close(FilevarM);
  124.    End
  125.    Else                            {couldn't find file}
  126.      Begin
  127.        GoToXY(1,24);
  128.        Write('ERROR - Could not find file');
  129.      End;
  130. END;
  131.  
  132. END.
  133.